#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<vector<int>> dp(k + 1, vector<int>(n + 1, -1e18));
    dp[0][0] = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int m = 1; m <= 6; m++)
            {
                if (j - m >= 0)
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - m] + a[j - 1]);
            }
        }
    }
    int ans = -1e18;
    for (int j = 1; j <= n; ++j)
        ans = max(ans, dp[k][j]);
    cout << ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}